<template>
  <div>
    <h2 style="text-align: center">退货订单</h2>
    <el-table :data="returnList" stripe height="300" style="width: 100%">
      <el-table-column type="expand">
        <template #default="props">
          <span style="margin-left: 30px;font-weight: bold">商品详情</span>
          <el-table :data="props.row.goodsList" stripe style="margin-left: 20px;">
            <el-table-column label="商品名" prop="supplyGoods.goodsName"/>
            <el-table-column label="类型" prop="supplyGoods.type"/>
            <el-table-column label="品牌" prop="supplyGoods.brand"/>
            <el-table-column label="颜色" prop="supplyGoods.color"/>
            <el-table-column label="大小" prop="supplyGoods.size"/>
            <el-table-column label="进货价" prop="supplyGoods.price"/>
            <el-table-column label="数量" prop="num"/>
          </el-table>
        </template>
      </el-table-column>

      <el-table-column label="退货单编号" prop="returnId"/>
      <el-table-column label="退货原因" prop="reason"/>
      <el-table-column label="总价" prop="sumPrice"/>
      <el-table-column label="时间" prop="time"/>
      <el-table-column label="退货状态" prop="status"/>
      <el-table-column label="操作">
        <template #default="scope">
          <el-button v-if="scope.row.status!=='已完成'" size="default" type="primary" @click="complete(scope.row.id)">
            完成退货
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <el-pagination
        v-model:current-page="currentPage"
        v-model:page-size="pageSize"
        background
        layout="prev, pager, next, jumper"
        :total="total"
        @current-change="find"
    />
  </div>
</template>

<script>
import axios from "axios";


export default {
  data() {
    return {
      returnList: [],
      total: 0,
      currentPage: 1,
      pageSize: 6,

    }
  },
  methods: {
    find(pageNO) {
      this.currentPage = pageNO
      axios.get("/project/return/find", {params: {pageNO}})
          .then(resp => {
            let obj = resp.data;
            if (obj.success) {
              this.returnList = obj.data.records;
              this.total = obj.data.total;
              this.pageSize = obj.data.size
            }
          })
    },
    findById(id) {
      axios.get("/project/return/findById", {params: {id}}).then(resp => {
        let obj = resp.data
        if (obj.success){

        }
      })
    },
    complete(id) {
      axios.get("/project/return/complete", {params: {id}})
          .then(resp => {
            let obj = resp.data;
            if (obj.success) {
              this.find(this.currentPage);
            }
          })
    }
  },
  created() {
    this.find(1);
  }
}
</script>

<style scoped>

</style>